package com.gw.detail.controllor.detail;

import java.util.List;

import com.gw.detail.domain.Fzgi;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gw.detail.service.IFzgiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆内部Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/fzgi")
public class FzgiController extends BaseController
{
    @Autowired
    private IFzgiService fzgiService;

    /**
     * 查询车辆内部列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fzgi fzgi)
    {
        startPage();
        List<Fzgi> list = fzgiService.selectFzgiList(fzgi);
        return getDataTable(list);
    }

    /**
     * 导出车辆内部列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:export')")
    @Log(title = "车辆内部", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Fzgi fzgi)
    {
        List<Fzgi> list = fzgiService.selectFzgiList(fzgi);
        ExcelUtil<Fzgi> util = new ExcelUtil<Fzgi>(Fzgi.class);
        return util.exportExcel(list, "车辆内部数据");
    }

    /**
     * 获取车辆内部详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fzgiService.selectFzgiById(id));
    }

    /**
     * 新增车辆内部
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:add')")
    @Log(title = "车辆内部", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fzgi fzgi)
    {
        return toAjax(fzgiService.insertFzgi(fzgi));
    }

    /**
     * 修改车辆内部
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:edit')")
    @Log(title = "车辆内部", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fzgi fzgi)
    {
        return toAjax(fzgiService.updateFzgi(fzgi));
    }

    /**
     * 删除车辆内部
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgi:remove')")
    @Log(title = "车辆内部", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fzgiService.deleteFzgiByIds(ids));
    }
}
